#region

using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using Vin.Extension.Framework.Upload.Options;
using Vin.Extension.Framework.Upload.ServiceInterface;
using Vin.Tool.AspNetCore.Service;
using Vin.Tool.Attributes;

#endregion

namespace Vin.Extension.Framework.Upload.Service;

[Service("local")]
public class UploadService : VinBaseService, IUploadService
{
    [Inject] private readonly LocalFileService _localFileService = null!;

    [Inject] private readonly IOptionsMonitor<UploadOption> _uploadOption = null!;

    public async Task<string> UploadFileAsync(IFormFile file, string? baseDir = null)
    {
        return await _localFileService.UploadAsync(file, baseDir ?? _uploadOption.CurrentValue.BaseDir);
    }

    public async Task<string> UploadFileAsync(byte[] file, string extension, string? baseDir = null)
    {
        return await _localFileService.UploadAsync(file, extension, baseDir ?? _uploadOption.CurrentValue.BaseDir);
    }
}